package com.framework.modules.base.dao;

import com.framework.modules.base.entity.UserSpaceEntity;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 *  
 * 
 * @author MIT
 * @email litmiss@gmail.com
 * @date 2020-10-24 07:56:23
 */
public interface UserSpaceDao extends BaseMapper<UserSpaceEntity> {

    /**
     * 更新关注数
     * @return
     */
    @Update("update tb_user_space set attent_count=#{attentCount} where uid=#{id}")
    Integer updateLikeCount(@Param("id")Integer id,@Param("attentCount")Integer attentCount);

    /**
     * 更新关注数+1
     * @return
     */
    @Update("update tb_user_space set attent_count=attent_count+1 where uid=#{id}")
    Integer addLikeCount(@Param("id")Integer id);

    /**
     * 更新关注数-1
     * @return
     */
    @Update("update tb_user_space set attent_count=attent_count-1 where uid=#{id}")
    Integer reduceLikeCount(@Param("id")Integer id);

    /**
     * 更新粉丝数
     * @return
     */
    @Update("update tb_user_space set fans_count=#{fansCount} where uid=#{id}")
    Integer updateFansCount(@Param("id")Integer id,@Param("fansCount")Integer fansCount);

    /**
     * 更新关粉丝数+1
     * @return
     */
    @Update("update tb_user_space set fans_count=fans_count+1 where uid=#{id}")
    Integer addFansCount(@Param("id")Integer id);

    /**
     * 更新粉丝数-1
     * @return
     */
    @Update("update tb_user_space set fans_count=fans_count-1 where uid=#{id}")
    Integer reduceFansCount(@Param("id") Integer id);

    Integer saveOrUpdateBatch(@Param("list") List<UserSpaceEntity> list);
	
}
